package cn.edu.xhu.base;

import java.lang.reflect.ParameterizedType;

import javax.annotation.Resource;

import cn.edu.xhu.service.TestService;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class BaseAction<T> extends ActionSupport implements ModelDriven<T>{
	
	@Resource
	protected TestService testService;
	
	protected T model;
	
	public BaseAction() {
		try {
			ParameterizedType parameterizedType = (ParameterizedType) this.getClass().getGenericSuperclass();
			Class<T> clazz = (Class<T>) parameterizedType.getActualTypeArguments()[0];
			model = clazz.newInstance();
		} catch (Exception exception) {
			throw new RuntimeException();
		}
	}
	
	@Override
	public T getModel() {
		return model;
	}
	
}
